package common.service.util;

import java.security.SecureRandom;
import java.util.UUID;

/**
 * 令牌工具类
 * @author YU
 *
 */
public class TokenUtil {
	
	public final static String tokenTag="__mobileToken";
	
	private static SecureRandom rdm=null;
	static{
		byte bt[] =SecureRandom.getSeed(32);
		 rdm=new SecureRandom(bt);	
	}
	
	/**
	 * 生成随机数
	 * @return
	 */
	public static String getToken(){
		return (rdm.nextLong()+"").replace("-","1");
	}	
	/**
	 * 获取长度为2随机数
	 * @return
	 */
	public static String  get2Randomint(){
		int randomInt = rdm.nextInt(100);
		if(randomInt<10){
			return "0"+randomInt;
		}
		return randomInt+"";
	}
	/**
	 * 生成uuid
	 * @return
	 */
	public static String getUUID(){
		String uuid = UUID.randomUUID().toString();
		uuid = uuid.replaceAll("-", "");
		return uuid;
	}
}


